<template>
  <div class="not-found-container">
    <div class="not-found-content">
      <!-- 404图标 -->
      <div class="icon-section">
        <div class="error-code">404</div>
        <el-icon class="error-icon">
          <Warning />
        </el-icon>
      </div>
      
      <!-- 错误信息 -->
      <div class="text-section">
        <h1>页面不存在</h1>
        <p class="subtitle">抱歉，您访问的页面不存在或已被删除</p>
        <p class="description">
          请检查URL是否正确，或者返回首页继续浏览
        </p>
      </div>
      
      <!-- 路径信息 -->
      <div class="info-section">
        <el-card class="info-card">
          <div class="info-item">
            <span class="label">访问路径：</span>
            <span class="value">{{ currentPath }}</span>
          </div>
          <div class="info-item">
            <span class="label">错误时间：</span>
            <span class="value">{{ currentTime }}</span>
          </div>
        </el-card>
      </div>
      
      <!-- 操作按钮 -->
      <div class="action-section">
        <el-button type="primary" @click="goHome" size="large">
          <el-icon><House /></el-icon>
          返回首页
        </el-button>
        <el-button @click="goBack" size="large">
          <el-icon><ArrowLeft /></el-icon>
          返回上一页
        </el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { computed, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { Warning, House, ArrowLeft } from '@element-plus/icons-vue'

const route = useRoute()
const router = useRouter()

// 当前路径
const currentPath = computed(() => route.fullPath)

// 当前时间
const currentTime = ref('')

// 返回首页
const goHome = () => {
  router.push('/index')
}

// 返回上一页
const goBack = () => {
  if (window.history.length > 1) {
    router.go(-1)
  } else {
    goHome()
  }
}

// 格式化当前时间
const formatCurrentTime = () => {
  const now = new Date()
  currentTime.value = now.toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit'
  })
}

onMounted(() => {
  formatCurrentTime()
})
</script>

<style scoped>
.not-found-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  padding: 20px;
}

.not-found-content {
  text-align: center;
  max-width: 600px;
  width: 100%;
}

.icon-section {
  position: relative;
  margin-bottom: 40px;
}

.error-code {
  font-size: 120px;
  font-weight: bold;
  color: #e74c3c;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  font-family: 'Arial', sans-serif;
}

.error-icon {
  font-size: 60px;
  color: #f39c12;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

.text-section {
  margin-bottom: 40px;
}

.text-section h1 {
  font-size: 32px;
  color: #2c3e50;
  margin-bottom: 16px;
  font-weight: 600;
}

.subtitle {
  font-size: 18px;
  color: #7f8c8d;
  margin-bottom: 12px;
  line-height: 1.5;
}

.description {
  font-size: var(--font-size-base);
  color: #95a5a6;
  line-height: 1.6;
  margin: 0;
}

.info-section {
  margin-bottom: 40px;
}

.info-card {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #ecf0f1;
}

.info-item:last-child {
  border-bottom: none;
}

.label {
  font-weight: 500;
  color: #34495e;
  font-size: var(--font-size-base);
}

.value {
  color: #7f8c8d;
  font-size: var(--font-size-base);
  font-family: 'Courier New', monospace;
}

.action-section {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.action-section .el-button {
  min-width: 140px;
  height: 44px;
  font-size: 16px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.action-section .el-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}


</style>
